<div class="nav-sub w1180">
	<ul class="zoom">
		<li><a class="on" href="">新增商户</a></li>
		<li><a href="/crm/org/list">商户列表</a></li>
		<li><a href="/crm/org/goods-list">商品列表</a></li>
	</ul>
</div>
<div class="main-ct w1180">
	<a href="javascript:history.go(-1);" class="btn-cs btn-blue btn-fillet mt10">返 回</a>
<form id="commonForm" method="post" action="/crm/org/insert">
	<div class="form-info mt20">
	
		<dl>
			<dt>商户类型：</dt>
			<dd>
			<label class="mr20"><input type="radio" name="org_type" checked="true" value="1"> 配餐类</label>
			<label class="mr20"><input type="radio" name="org_type" value="2"> 商城类</label>
			</dd>
		</dl>
		<dl>
			<dt>是否直营：</dt>
			<dd>
			<label class="mr20"><input type="radio" name="org_is_direct_sale" checked="true" value="1"> 非直营</label>
			<label class="mr20"><input type="radio" name="org_is_direct_sale" value="2"> 直营</label>
			</dd>
		</dl>
		<dl>
			<dt>商户所属分类：</dt>
			<dd>
			<select name="catalog_id">
				<option value="">请选择</option>
				<?php if ($this->catalog):?>
    			<?php foreach ($this->catalog as $k=>$v):?>
        			<option value="<?php echo $v['catalog_id']; ?>"><?php echo $v['catalog_name']; ?></option>
        		<?php endforeach; ?>
    			<?php endif;?>
			</select>
			</dd>
		</dl>
		
		<dl>
			<dt>商户名称：</dt>
			<dd><input type="text" class="txt" name="org_name" ></dd>
		</dl>
		
		<dl>
			<dt>商户主标题：</dt>
			<dd><input type="text" class="txt" name="org_title" ></dd>
		</dl>
		
		<dl>
			<dt>商户副标题：</dt>
			<dd><input type="text" class="txt" name="org_subtitle" ></dd>
		</dl>
		
		<dl>
			<dt>商户简介：</dt>
			<dd><textarea class="txt" name="org_description"></textarea></dd>
		</dl>
		
		<dl>
			<dt>商户特色：</dt>
			<dd><textarea class="txt" name="org_features"></textarea></dd>
		</dl>
		
		<dl>
			<dt>商户公告：</dt>
			<dd><textarea class="txt" name="org_advice"></textarea></dd>
		</dl>
		
		<dl>
			<dt>商户卫生等级：</dt>
			<dd>
			<label class="mr20"><input type="radio" name="org_level" checked="true" value="1"> A</label>
			<label class="mr20"><input type="radio" name="org_level" value="2"> B</label>
			<label class="mr20"><input type="radio" name="org_level" value="3"> C</label>
			<label><input type="radio" name="org_level" value="4"> D</label>
			</dd>
		</dl>

		<dl>
			<dt>商户直播开关：</dt>
			<dd>
			<label class="mr20"><input type="radio" name="org_is_open" checked="true" value="1"> 开启</label>
			<label class="mr20"><input type="radio" name="org_is_open" value="0"> 关闭</label>
		</dl>
		
		<dl>
			<dt>厨房直播链接：</dt>
			<dd><input type="text" class="txt" name="org_live" ></dd>
		</dl>
		
		<dl>
			<dt>下次直播预告：</dt>
			<dd><textarea  class="txt" name="org_next_notice" id=""></textarea></dd>
		</dl>
		
		<dl>
			<dt>联系人：</dt>
			<dd><input type="text" class="txt" name="org_contact_name" ></dd>
		</dl>
		
		<dl>
			<dt>商户地址：</dt>
			<dd><textarea  class="txt" name="org_address" id=""></textarea></dd>
		</dl>
		
		<dl>
			<dt>商户地址图片：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-address_img">
						<img src="/images/ico/ico-add.png"  id="add-address_img">
						<input type="hidden" name="address_img" id="address_img">
					</div>
					<a href="javascript:;" class="btn-del" id="del-address_img" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
        
<!--         <dl> -->
<!-- 			<dt>商户资质（最多8张）：</dt> -->
<!-- 			<dd class="goods-list" id="show-org-logo"> -->
<!-- 				<div class="goods-img goods-img-add"> -->
<!-- 					<div class="g-img-ct"  id="cover1"> -->
<!-- 						<img src="/images/ico/ico-add.png"> -->
<!-- 					</div> -->
<!-- 				</div> -->
<!-- 			</dd> -->
<!-- 		</dl> -->
		
		<!-- 单传八张 -->
		
		<dl>
			<dt>营业执照：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img1">
						<img src="/images/ico/ico-add.png"  id="add-org_img1">
						<input type="hidden" name="org_img1" id="org_img1">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img1" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
		<dl>
			<dt>税务登记证：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img2">
						<img src="/images/ico/ico-add.png"  id="add-org_img2">
						<input type="hidden" name="org_img2" id="org_img2">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img2" style="display:none"></a>
				</div>
			</dd>
		</dl>	
		
		<dl>
			<dt>组织机构代码证：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img3">
						<img src="/images/ico/ico-add.png"  id="add-org_img3">
						<input type="hidden" name="org_img3" id="org_img3">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img3" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
		<dl>
			<dt>食品经营许可证：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img4">
						<img src="/images/ico/ico-add.png"  id="add-org_img4">
						<input type="hidden" name="org_img4" id="org_img4">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img4" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
		<dl>
			<dt>食品流通许可证：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img5">
						<img src="/images/ico/ico-add.png"  id="add-org_img5">
						<input type="hidden" name="org_img5" id="org_img5">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img5" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
		<dl>
			<dt>餐饮服务食品安全等级：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img6">
						<img src="/images/ico/ico-add.png"  id="add-org_img6">
						<input type="hidden" name="org_img6" id="org_img6">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img6" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
		
		<dl>
			<dt>食品安全管理体系认证：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add">
					<div class="g-img-ct"  id="cover-org_img7">
						<img src="/images/ico/ico-add.png"  id="add-org_img7">
						<input type="hidden" name="org_img7" id="org_img7">
					</div>
					<a href="javascript:;" class="btn-del" id="del-org_img7" style="display:none"></a>
				</div>
			</dd>
		</dl>

		
		
		<dl>
			<dt>商户logo：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add" id="">
					<div class="g-img-ct"  id="cover">
						<img src="/images/ico/ico-add.png"  id="add-org_logo">
						<input type="hidden" name="org_logo" id="org_logo">
					</div>
					<a href="javascript:delImg(this);" class="btn-del" id="del-org_logo" style="display:none"></a>
				</div>
			</dd>
		</dl>

		<dl>
			<dt>商户图片(列表)：</dt>			
			<dd class="goods-list">
				<div class="goods-img goods-img-add" id="">
					<div class="g-img-ct"  id="cover-thumb_image">
						<img src="/images/ico/ico-add.png"  id="add-org_thumb_image">
						<input type="hidden" name="org_thumb_image" id="org_thumb_image">
					</div>
					<a href="javascript:delImg(this);" class="btn-del" id="del-org_thumb_image" style="display:none"></a>
				</div>
			</dd>
		</dl>
		
		
		
<!-- 		<dl> -->
<!--             <dt>商户展示（图片）：</dt> -->
<!--             <dd><textarea name="org_details" id="container" class="col-sm-10" ></textarea></dd> -->
<!--         </dl> -->
       
			
        
        <dl>
			<dt>是否显示：</dt>
			<dd>
			<label class="mr20"><input type="radio" name="org_is_display" checked="true" value="1"> 显示</label>
			<label class="mr20"><input type="radio" name="org_is_display" value="0"> 不显示</label>
			</dd>
		</dl>
		
		<dl>
			<dt>其它：</dt>
			<dd><textarea  class="txt" name="org_other"></textarea></dd>
		</dl>
		
		 <dl>
			<dt>商户展示图片（多张）：</dt>
			<dd class="goods-list" id="show-org_details">
				<div class="goods-img  goods-img-add">
					<div class="g-img-ct"  id="cover_org_details">
						<img src="/images/ico/ico-add.png">
					</div>
				</div>
			</dd>
		</dl>
		<dl class="tips-line"><dt>&nbsp;</dt><dd>商家展示图片尺寸：** * **</dd></dl>
		

	</div>
<!-- 	<a class="btn-cs btn-l btn-fillet btn-blue mt20 ml50 btn-add-more" href="javascript:;">+添加更多</a> -->
	<p class="mt30 txt-center">
		<input class="input-cs btn-fillet btn-green" type="submit" value="确定" />
		<input class="input-cs btn-fillet mr20" type="reset" value="取消" />
	</p>
</form>
</div>

<script type="text/javascript" src="/plugins/webUpload/webuploader.js"></script>
<script type="text/javascript">
var orgDetailsUploader = WebUploader.create({
    		// 选完文件后，是否自动上传。
    		fileNumLimit: 8,
    		auto: true,
    		duplicate:1,
    		swf:'/plugins/webUpload/Uploader.swf',
    		server: '/crm/shop/ajax-upload',
    		pick: {
    			id:'#cover_org_details',
    			multiple:true
    		},
    		formData :{
    			path:"/org",
    		},
    		method :'post',
    		accept: {
    			title: 'Images',
    			extensions: 'gif,jpg,jpeg,png',
    			mimeTypes: 'image/*'
    		}
    	});
    
	orgDetailsUploader.on('uploadSuccess',function(file,response){
    		if(response.state == 'SUCCESS'){
        		var html='';
        		html +=	'<div class="goods-img goods-img-add">'
    						+ '<div class="g-img-ct">'
    					    + '<img src="'+ response.url +'">'
    					    + '<input type="hidden" name="'+ file.id +'" value="'+ response.url +'">'
    						+ '</div>'
    						+ '<a class="btn-del" href="javascript:delImg();"></a>'
    						+ '</div>';
    			$('#show-org_details').append(html);
    		}
    	});

var addressUploader = WebUploader.create({
    	// 选完文件后，是否自动上传。
    	fileNumLimit: 1,
    	auto: true,
    	duplicate:1,
    	swf:'/plugins/webUpload/Uploader.swf',
    	server: '/crm/shop/ajax-upload',
    	pick: {
    		id:'#cover-address_img',
    		multiple:false
    	},
    	formData :{
    		path:"/org/address",
    	},
    	method :'post',
    	accept: {
    		title: 'Images',
    		extensions: 'gif,jpg,jpeg,png',
    		mimeTypes: 'image/*'
    	}
    });

	addressUploader.on('uploadSuccess',function(file,response){
    	if(response.state == 'SUCCESS'){
    		$('#add-address_img').attr("src",response.url);
     		$('#address_img').val(response.url);
     		//$('#del-material_supplier_img1').show();
    		
    	}
    });
    

var uploader1 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img1',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader1.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img1').attr("src",response.url);
         		$('#org_img1').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });


var uploader2 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img2',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader2.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img2').attr("src",response.url);
         		$('#org_img2').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });


var uploader3 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img3',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader3.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img3').attr("src",response.url);
         		$('#org_img3').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });

var uploader4 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img4',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader4.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img4').attr("src",response.url);
         		$('#org_img4').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });


var uploader5 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img5',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader5.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img5').attr("src",response.url);
         		$('#org_img5').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });

var uploader6 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img6',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader6.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img6').attr("src",response.url);
         		$('#org_img6').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });

var uploader7 = WebUploader.create({
        	// 选完文件后，是否自动上传。
        	fileNumLimit: 1,
        	auto: true,
        	duplicate:1,
        	swf:'/plugins/webUpload/Uploader.swf',
        	server: '/crm/shop/ajax-upload',
        	pick: {
        		id:'#cover-org_img7',
        		multiple:false
        	},
        	formData :{
        		path:"/org",
        	},
        	method :'post',
        	accept: {
        		title: 'Images',
        		extensions: 'gif,jpg,jpeg,png',
        		mimeTypes: 'image/*'
        	}
        });
    
        uploader7.on('uploadSuccess',function(file,response){
        	if(response.state == 'SUCCESS'){
        		$('#add-org_img7').attr("src",response.url);
         		$('#org_img7').val(response.url);
         		//$('#del-material_supplier_img1').show();
        		
        	}
        });
        	
var uploader = WebUploader.create({
    	auto: true,
    	duplicate:1,
    	swf:'/plugins/webUpload/Uploader.swf',
    	server: '/crm/shop/ajax-upload',
    	pick: {
    		id:'#cover',
    		multiple:true
    	},
    	formData :{
    		path:"/org",
    	},
    	method : 'post',
    	accept: {
    		title: 'Images',
    		extensions: 'gif,jpg,jpeg,png',
    		mimeTypes: 'image/*'
    	}
    });

    uploader.on('uploadSuccess',function(file,response){
    	//alert(file.id);
    	console.log(file);
    	console.log(response);
    	if(response.state == 'SUCCESS'){
     		$('#add-org_logo').attr("src",response.url);
     		$('#org_logo').val(response.url);
     		//$('#del-org_logo').show();
    		
    	}
    });

        	

var orgListUploader = WebUploader.create({
        		auto: true,
        		duplicate:1,
        		swf:'/plugins/webUpload/Uploader.swf',
        		server: '/crm/shop/ajax-upload',
        		pick: {
        			id:'#cover-thumb_image',
        			multiple:true
        		},
        		formData :{
        			path:"/org",
        		},
        		method : 'post',
        		accept: {
        			title: 'Images',
        			extensions: 'gif,jpg,jpeg,png',
        			mimeTypes: 'image/*'
        		}
        	});
        
			orgListUploader.on('uploadSuccess',function(file,response){
        		//alert(file.id);
        		console.log(file);
        		console.log(response);
        		if(response.state == 'SUCCESS'){
        	 		$('#add-org_thumb_image').attr("src",response.url);
        	 		$('#org_thumb_image').val(response.url);
        	 		//$('#del-org_thumb_image').show();
        			
        		}
        	});


        	
$(function(){
     $(".btn-del").click(function() {
    	 $(this).parent("div").remove(); 
     });
});


function delImg(){

	$(".btn-del").click(function() {
    	 $(this).parent("div").remove(); 
     });
	
}
	
    $().ready(function() {
    	$("#commonForm").validate({
    		debug:true,
    		rules: {
    			org_name: {
    				required: true
    			},
    			org_title: {
    				required: true
    			},
    			org_subtitle: {
    				required: true
    			},
    			org_features: {
    				required: true
    			},
    			org_advice: {
    				required: true
    			},
    			org_live: {
    				required: true
    			},
    			org_level: {
    				required: true
    			},
    			catalog_id: {
    				required: true
    			},
    			org_contact_name: {
    				required: true
    			},
    			org_address: {
    				required: true
    			},
    			org_description: {
    				required: true
    			},
    			org_logo: {
    				required: true
    			}
    		},
    		submitHandler:function(form){ 
    	            form.submit();
    	    }   
    	});
    
    });

</script>